home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00084_Script_DB CLICK BROWSER < prev    next >
Text File  |  1996-03-28  |  5KB  |  180 lines

  1. -- ---------------------------------------------------------------
  2. -- Handler doClickBrowser: (1) hilites the topic name the user
  3. -- clicked on, (2) shows its description.
  4.  
  5. on doClickBrowser
  6.   chooseTopicInBrowser(the mouseLine)
  7. end
  8.  
  9. -- ---------------------------------------------------------------
  10. -- Handler clickedBrowserHilite  
  11.  
  12. on clickedBrowserHilite
  13.   global clickedLine
  14.   
  15.   chooseTopicInBrowser clickedLine
  16. end
  17.  
  18. -- ---------------------------------------------------------------
  19. -- Handler chooseTopicInBrowser
  20.  
  21. on chooseTopicInBrowser whichLine
  22.   -- the following if statement is used in case the user clicks
  23.   -- something on the browser and then moves the mouse over another
  24.   -- field. (if the above case did occur, clickedLine would be -1 and
  25.   -- the hilit topic would appear above the find button)
  26.   set lClickedTopic = line whichLine of field "browser"
  27.   
  28.   if (whichLine > 0) and (lClickedTopic <> "") then
  29.     -- clear the screen from the previous topic
  30.     clearDatabase
  31.     
  32.     -- hilite the clicked topic in the browser
  33.     selectTopic(whichLine)
  34.     
  35.     -- show the clicked topic
  36.     showSelectedTopic
  37.   end if
  38. end
  39.  
  40. -- --------------------------------------------------------
  41. -- Handler selectTopic selects the topic in the given line 
  42. -- of the browser.
  43.  
  44. on selectTopic whichLine
  45.   global clickedTopic, clickedLine
  46.   
  47.   set clickedLine = whichLine
  48.   set clickedTopic = line clickedLine of field "browser"
  49.   
  50.   hiliteClickedTopic
  51.   updateStage -- to show hiliting as soon as possible
  52. end
  53.  
  54. -- --------------------------------------------------------
  55. -- Handler showSelectedTopic (1) shows the text of the clicked
  56. -- topic, (2) shows the title of the clicked topic and (3)
  57. -- sets the buttons of the clicked topic.
  58. -- It is called from findUserTypedTopic and doClickBrowser
  59.  
  60. on showSelectedTopic
  61.   global textButton, mode
  62.   
  63.   setBrowserTopicsLine
  64.   showTitle
  65.   setTopicButtons
  66.   setNumPagesInClickedTopic
  67.   setNumPicturesInClickedTopic
  68.   
  69.   if (mode = "index") or (mode = "search") then
  70.     showText
  71.   else if (mode = "media") then
  72.     showPicture
  73.   end if
  74.   
  75.   updateStage  
  76. end
  77.  
  78. -- ---------------------------------------------------------------
  79. -- Handler hiliteClickedTopic hilites the clicked line in the browser.
  80.  
  81. on hiliteClickedTopic
  82.   global clickedLine, hilitTopic, clickedTopic, browser
  83.   global browserLineHeight
  84.   
  85.   put " " into cast "hilitTopic"
  86.   set the locV of sprite hilitTopic = (the top of sprite browser) + (clickedLine-1) * (browserLineHeight)
  87.   
  88.   put clickedTopic into cast "hilitTopic"
  89. end
  90.  
  91. -- ---------------------------------------------------------------
  92. -- Handler unhiliteClickedTopic clears the last hilit line.
  93.  
  94. on unhiliteClickedTopic
  95.   global hilitTopic
  96.   
  97.   removeFromStage(hilitTopic)
  98. end
  99.  
  100. -- ---------------------------------------------------------------
  101. -- Handler showTitle displays the title of the clickedTopic in the
  102. -- field "Topic Title".
  103.  
  104. on showTitle
  105.   global clickedTopic
  106.   
  107.   -- first, remove old styles
  108.   put " " into cast "Topic Title"
  109.   set the textStyle of cast "Topic Title" = "plain"
  110.   
  111.   -- now, add the new style
  112.   if isPictureTitle(clickedTopic) then
  113.     set the textStyle of cast "Topic Title" = "bold,italic"
  114.   else
  115.     set the textStyle of cast "Topic Title" = "bold"
  116.   end if
  117.   
  118.   put clickedTopic into cast "Topic Title"
  119.   
  120.   -- set the forecolor  of cast "Topic Title" to 255
  121. end
  122.  
  123. -- ---------------------------------------------------------------
  124. -- Handler showTopicText shows the text of the clicked topic.
  125. -- It uses binary search on pre-compiled lookup tabel which is faster
  126. -- than having Director get castnum of named cast.
  127. -- Also, calling setTopicTextAttributes with a castNum instead of
  128. -- castName saves several lookups by Director.
  129.  
  130. on showTopicText
  131.   global textSprite, clickedTopic, currentPage
  132.   
  133.   -- switch cast members instead of copying text over to preserve
  134.   -- the text styles and colors of each field.
  135.   set textcastNum = getTextCastNumber(clickedTopic, currentPage)
  136.   
  137.   if (textcastNum = -1) then
  138.     set clickedTopic = getEquivalentTerm(clickedTopic)
  139.     exit
  140.   end if
  141.   
  142.   setTopicTextAttributes(textcastNum)
  143.   
  144.   set the castNum of sprite textSprite = textcastNum
  145.   
  146.   showMoreButtons
  147.   
  148.   setClearedFlag(False)
  149.   updatestage
  150. end
  151.  
  152. -- ---------------------------------------------------------------
  153. -- Handler setBrowserTopicsLine sets the global variable
  154. -- browserTopicsLine to the corresponding line of the field
  155. -- "browserTopics" that was clicked.
  156.  
  157. on setBrowserTopicsLine
  158.   global clickedTopic, browserTopicsLine, browserTopics, masterBrowserTopics
  159.   
  160.   if (clickedTopic = "") then
  161.     set browserTopicsLine = 0
  162.   else
  163.     set foundLine =  binSearchFirstItemInLine(masterBrowserTopics, clickedTopic, ":")
  164.     if foundLine then 
  165.       set browserTopicsLine  = foundLine
  166.       set oldDelimiter = the itemDelimiter
  167.       set the itemDelimiter = ":"
  168.       set clickedTopic = item 1 of line foundLine of masterBrowserTopics -- to get correct capitalization
  169.       set the itemDelimiter = oldDelimiter
  170.     else 
  171.       nothing
  172.       -- alert("foundLine = 0 in setBrowserTopicsLine")
  173.     end if
  174.   end if
  175. end
  176.  
  177. on removeFromStage whichSprite
  178.   set the locV of sprite whichSprite = 1000
  179.   updateStage
  180. end